#include "ShipInput.hpp"

// Constructor to initialize all the correct values.
ShipInput::ShipInput()
{
	m_nPitchDirection = PITCH_NEUTRAL;
	m_nTurnDirection = TURN_NEUTRAL;
	m_nRollDirection = ROLL_NEUTRAL;
	m_nThrottleDirection = THROTTLE_NEUTRAL;

	float m_fThrottlePosition = 0.0f;
}

void ShipInput::injectKeyPressed(const OIS::KeyEvent& keyEventRef)
{
	// Handle player input for the ship.
	switch (keyEventRef.key)
	{
	case OIS::KC_W: 
		m_nPitchDirection = PITCH_DOWN;
		break;
	case OIS::KC_S: 
		m_nPitchDirection = PITCH_UP;
		break;

	case OIS::KC_A: 
		m_nTurnDirection = TURN_LEFT;
		break;
	case OIS::KC_D: 
		m_nTurnDirection = TURN_RIGHT;
		break;

	case OIS::KC_Q: 
		m_nRollDirection = ROLL_LEFT;
		break;
	case OIS::KC_E: 
		m_nRollDirection = ROLL_RIGHT;
		break;

	case OIS::KC_R: 
		m_nThrottleDirection = THROTTLE_INCREASE;
		break;
	case OIS::KC_F: 
		m_nThrottleDirection = THROTTLE_DECREASE;
		break;
	}
}

void ShipInput::injectKeyReleased(const OIS::KeyEvent& keyEventRef)
{
	// Handle player input for the ship.
	switch (keyEventRef.key)
	{
		case OIS::KC_W:
		case OIS::KC_S: 
			m_nPitchDirection = PITCH_NEUTRAL;
			break;

		case OIS::KC_A:
		case OIS::KC_D: 
			m_nTurnDirection = TURN_NEUTRAL;
			break;

		case OIS::KC_Q: 
		case OIS::KC_E: 
			m_nRollDirection = ROLL_NEUTRAL;
			break;

		case OIS::KC_R: 
		case OIS::KC_F: 
			m_nThrottleDirection = THROTTLE_NEUTRAL;
			break;
	}
}